package abd.pr2.bd;

import javax.xml.namespace.QName;
import javax.xml.xquery.XQDataSource;
import javax.xml.xquery.XQException;
import javax.xml.xquery.XQPreparedExpression;
import javax.xml.xquery.XQResultSequence;

import org.w3c.dom.Element;

public class ConsultaNoticiaPorId extends ConsultaAbstracta<String> {

	private static final String ARCHIVO_CONSULTA_XQUERY = "4.xquery";
	private String id_noticia;
	
	public ConsultaNoticiaPorId(XQDataSource xqds, String id_noticia) {
		super(xqds);
		this.id_noticia = id_noticia;
		this.nombreArchivo = ARCHIVO_CONSULTA_XQUERY;
	}

	@Override
	public void addBinds(XQPreparedExpression exp) throws XQException {
		exp.bindString(new QName("id_noticia"), this.id_noticia, null);
	}

	@Override
	public String buildObject(XQResultSequence rs) throws XQException {
		return rs.getItemAsString(null);
	}
	
}
